Support jdeploy.args in package.json for JVM/program arguments#467
Merged
Conversation
…deploy.js launcher
The npm launcher (jdeploy.js) previously ignored the jdeploy.args array in
package.json, so publishers had to hand-edit the generated launcher to add JVM
flags like --add-opens after deploying. It now processes jdeploy.args at
runtime, mirroring the client4j (Go) launcher: platform-conditional prefixes
(-[mac], -D[win], -X[linux], pipe-OR groups) resolve on the running machine,
and --flag value options such as --add-opens are split into the two tokens the
JVM expects. Args are injected at publish time via a {{JAVA_ARGS}} placeholder.
Adds a platform-mocked unit test for the arg processing.
testJDeployScript performs its own placeholder substitution independent of
PackageService, and did not replace the new {{JAVA_ARGS}} token, leaving an
invalid `var packageArgs = {{JAVA_ARGS}};` in the generated launcher (Node
SyntaxError). Replace it with an empty array to match a package.json with no
jdeploy.args.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for declaring JVM and program arguments in package.json's
jdeploy.argsarray, which are injected into the generated jdeploy.js launcher. This mirrors the argument processing behavior of the client4j launcher, including platform-conditional syntax and proper splitting of multi-token JVM options.Key Changes
jdeploy.js launcher enhancements:
packageArgsvariable injected at publish time as a JSON array literalprocessPackageArg()function to resolve platform-conditional prefixes (-[conditions],-D[conditions],-X[conditions])appendPackageArgs()function to categorize arguments into JVM args (before-jar) and program args (after jar)--add-opens java.desktop/com.apple.eawt=ALL-UNNAMEDinto separate tokens-[mac|linux]) for multi-platform targetingPackageService.java:
toJavaArgsJson()method to serialize thejdeploy.argslist from package.json into a JSON array literalprocessJdeployTemplate()to inject the serialized args as{{JAVA_ARGS}}placeholderComprehensive test coverage:
package-args.test.jsregression test that extracts and tests the realprocessPackageArgandappendPackageArgsfunctions from jdeploy.jsprocess.platformto exercise all platform branches on any hostImplementation Details
The argument processing mirrors the client4j launcher's behavior:
-Dor-Xare treated as JVM arguments--(module/access options) are split on spaces to separate flag from value-pshort form of--module-pathis split into two tokenshttps://claude.ai/code/session_013aT4ipGJM1Wv1D5bhrPBj6